-
Notifications
You must be signed in to change notification settings - Fork 512
Arduino's EEPROMM.length() method should return the number of bytes a… #2507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino's EEPROMM.length() method should return the number of bytes a… #2507
Conversation
…vailable rather than the number of bytes written.
|
Thanks for the PR, but after re-reading the code it seems that the existing implementation is correct, returning the allocated size chosen by the user on start. For example, if you do |
|
Thanks for circling back to this... But I'm not seeing anything like that. Have you looked here? .begin() should return the starting address of the EEPROM and length should work as discussed. |
|
Not sure what
_size and returned for length().
|
|
I see that is how your version works--which is handy--but it breaks Arduino compatibility. And that's fine except for the name "arduino-pico" implies compatibility. Did you check the link to the actual Arduino library I sent? I linked it directly to the begin method which doesn't take any params in so if I use it the way your version is written, it will not work on an Arduino. Given that your version of begin has the correct value, wouldn't it make more sense to have it be in the constructor? That would allow you to have your cake and eat it too (happy to change the PR if that's what you're after). Sorry for the trouble. |
|
Yes, you will need to pass in the needed size so you'll need to ever so slightly modify the code. Even if we add a default parameter to the begin method like That said, in most cases |
|
To save us both some time, to be clear, you don't care about Arduino compatibility despite our brief exchange yesterday? As it stands, this behaves like an ESP32 not an Arduino which means there are breaking changes between the two. |
|
Physically there is no EEPROM on board, so we give it a best effort wrapper for really old AVR code. We do support the templated writes which seems to have covered most legacy use cases. I think you're trying to add in the iterator (but I don't think they actually subclassed FWIW, there's no EEPROM library, at all, on the official Arduino Nano RP2040 Connect MBED core (looking at the installed dirs). Physically, you cannot write to flash the same way as EEPROM, so this and the ESP cores add a commit() method to actually persist data. It's still not the same a EEPROM as in the EEPROM case physically you could probably expect to lose 1 byte worth of data...with flash you can lose the entire 4K if the powerfail happens after the erase and before rewrite. If you erased and rewrote after every byte change that would have a danger window around every byte and also make it much more likely to wear out the flash sector. That's where something like LittleFS comes in, with wear leveling and power fail safety and a lot more capabilities. |
|
Yeah, we've been over all of this. I am just trying to ensure consistent behavior. I appreciate the technical issues you have outlined and the thorough explanations. In my use case (and for the sake of Arduino compatibility), it makes sense. From my perspective, leveraging another tool that is massively overbuilt for the storing of 17-62 bytes that will likely not be rewritten more than monthly if ever on a device with an expected lifespan of ten years seems silly. I'll work on putting something together. Thank you for your time and perspective. |
As discussed in (#2506). I would have loved to test it but apparently the toolchain doesn't agree with my system.